const globalIp = getApp().globalData.userIp
Page({
  /**
   * 页面的初始数据
   */
  data: {
    searchResult:false,
    dataColor: false,
    dataTime:"日期选择",
    dataTime1:"日期选择",
    dataFlag: false, //控制综合下拉框是否显示
    isShowAll:false,
    projectList:[],
    openId:'',
    info:'',
    type:''
  },
  getInputValue: function(e){
    this.setData({
      info: e.detail.value
    })
  },
  selectData: function(){
    this.getProject();
  },
  // 统一请求
   getProject(e) {
    let that = this;
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    var length = 0;
    wx.request({
      url: globalIp + 'home/manage/ManagePost',
      data: {
        status: that.data.type || '',
        value: that.data.info || '',
        openId: that.data.openId || wx.getStorageSync('userInfo').openid,
        login: wx.getStorageSync('userInfo').login || 'N'
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        if (res.data.jsonObject) {
          length = res.data.jsonObject.data.length;
          var data = res.data.jsonObject.data;
          var arr = [];
          var res = [];
          for (var i in data) {
            arr[i] = [];
            for(var j in data[i]) {
              arr[i].push(data[i][j]);
            }
          }
          for (var i = 0; i < arr[0].length; ++i) {
            res[i] = [];
            for (var j = 0; j < arr.length; ++j) {
              res[i][j] = arr[j][i];
            }
          }
          that.setData({
            projectList: res
          })
        } 
      },
      fail: function(res) {
        wx.showToast({
          title: '请返回上一页面，重新请求',
          icon: 'none',
          duration: 2000,
        })
      },
      complete: function(res) {
        setTimeout(() => {
          wx.hideLoading()
        }, 15 * length)
      }
    })
  },

    /**
    * 生命周期函数--监听页面加载
    */
  onLoad(options) {
    this.setData({
      type: options.type || ''
    })
    if(options.type == 'Y') {
      wx.setNavigationBarTitle({
        title: '入职员工列表',
      })
    } else {
      wx.setNavigationBarTitle({
        title: '部门人员花名册',
      })
    }
    this.getProject();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
  
})